public class Sort5 {
    public static void bubbleSort(int[] array) {
        //i代表趟数 10个元素只用排9趟
        for (int i = 0; i < array.length-1; i++) {
            boolean flg = false;
            for (int j = 0; j < array.length-1-i; j++) {
                if (array[j+1] > array[j]) {
                    int tmp = array[j+1];
                    array[j+1] = array[j];
                    array[j] = tmp;
                    flg = true;
                }
            }
            //没有交换证明有序了
            if (flg==false) {
                return;
            }
        }
    }
}
